﻿<!--
Copyright © 2011 François Karman

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

See<license.txt>for the complete license of the software.
-->
<controls:Panorama x:Class="NUnit.Phone.Gui.ResultList"
                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                   xmlns:nunit="clr-namespace:NUnit.Phone.Gui"
                   xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
                   mc:Ignorable="d"
                   d:DesignHeight="480"
                   d:DesignWidth="480">

    <controls:Panorama.Resources>
        <nunit:Text x:Key="Text" />

        <DataTemplate x:Key="TestResultTemplate">
            <StackPanel Orientation="Vertical"
                        Margin="0,21,0,0">
                <TextBlock Text="{Binding Path=FullName}"
                           TextWrapping="Wrap"
                           Style="{StaticResource PhoneTextNormalStyle}" />
                <TextBlock Text="{Binding Path=ResultState.Label}"
                           TextWrapping="Wrap"
                           Style="{StaticResource PhoneTextSubtleStyle}" />
                <TextBlock Text="{Binding Path=Message}"
                           TextWrapping="Wrap"
                           Style="{StaticResource PhoneTextAccentStyle}" />
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="TestOutputTemplate">
            <StackPanel Orientation="Vertical"
                        Margin="0,21,0,0">
                <TextBlock Text="{Binding Path=Text}"
                           TextWrapping="Wrap"
                           Style="{StaticResource PhoneTextNormalStyle}" />
                <TextBlock Text="{Binding Path=Type}"
                           TextWrapping="Wrap"
                           Style="{StaticResource PhoneTextSubtleStyle}" />
            </StackPanel>
        </DataTemplate>

        <SolidColorBrush x:Key="FailColor"
                         Color="Red" />

        <SolidColorBrush x:Key="InconclusiveColor"
                         Color="DarkOrange" />

        <SolidColorBrush x:Key="SkipColor"
                         Color="Orange" />
    </controls:Panorama.Resources>

    <controls:PanoramaItem Header="{Binding Path=ResultExecutionSectionText, Source={StaticResource Text}}">
        <StackPanel>
            <ProgressBar Minimum="0"
                         Maximum="{Binding Path=TotalCount}"
                         Value="{Binding Path=ExecutedCount}"
                         HorizontalAlignment="Stretch" />
            <StackPanel Orientation="Horizontal"
                        Margin="{StaticResource PhoneHorizontalMargin}">
                <TextBlock Text="{Binding Path=ExecutedCount}"
                           Margin="0"
                           Style="{StaticResource PhoneTextAccentStyle}" />
                <TextBlock Text="/"
                           Margin="0"
                           Style="{StaticResource PhoneTextAccentStyle}" />
                <TextBlock Text="{Binding Path=TotalCount}"
                           Margin="0"
                           Style="{StaticResource PhoneTextAccentStyle}" />
            </StackPanel>

            <Grid x:Name="resultVertical"
                  Margin="0,21,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0"
                           Grid.Column="0"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=ResultPassText, Source={StaticResource Text}}" />
                <TextBlock Grid.Row="0"
                           Grid.Column="1"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=PassedTests.Count}" />
                <TextBlock Grid.Row="1"
                           Grid.Column="0"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=ResultFailText, Source={StaticResource Text}}" />
                <TextBlock Grid.Row="1"
                           Grid.Column="1"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=FailedTests.Count}" />
                <TextBlock Grid.Row="2"
                           Grid.Column="0"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=ResultInconclusiveText, Source={StaticResource Text}}" />
                <TextBlock Grid.Row="2"
                           Grid.Column="1"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=InconclusiveTests.Count}" />
                <TextBlock Grid.Row="3"
                           Grid.Column="0"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=ResultSkipText, Source={StaticResource Text}}" />
                <TextBlock Grid.Row="3"
                           Grid.Column="1"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=SkippedTests.Count}" />
            </Grid>

            <Grid x:Name="resultHorizontal"
                  Visibility="Collapsed"
                  Margin="0,21,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0"
                           Grid.Column="0"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=ResultPassText, Source={StaticResource Text}}" />
                <TextBlock Grid.Row="0"
                           Grid.Column="1"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=PassedTests.Count}" />
                <TextBlock Grid.Row="1"
                           Grid.Column="0"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=ResultFailText, Source={StaticResource Text}}" />
                <TextBlock Grid.Row="1"
                           Grid.Column="1"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=FailedTests.Count}" />
                <TextBlock Grid.Row="0"
                           Grid.Column="2"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=ResultInconclusiveText, Source={StaticResource Text}}" />
                <TextBlock Grid.Row="0"
                           Grid.Column="3"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=InconclusiveTests.Count}" />
                <TextBlock Grid.Row="1"
                           Grid.Column="2"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=ResultSkipText, Source={StaticResource Text}}" />
                <TextBlock Grid.Row="1"
                           Grid.Column="3"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           Text="{Binding Path=SkippedTests.Count}" />
            </Grid>
        </StackPanel>
    </controls:PanoramaItem>

    <controls:PanoramaItem Header="{Binding Path=ResultFailSectionText, Source={StaticResource Text}}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <ProgressBar Grid.Row="0"
                         Minimum="0"
                         Maximum="{Binding Path=TotalCount}"
                         Value="{Binding Path=FailedTests.Count}"
                         Foreground="{StaticResource FailColor}"
                         HorizontalAlignment="Stretch" />
            <StackPanel Grid.Row="1"
                        Orientation="Horizontal"
                        Margin="{StaticResource PhoneHorizontalMargin}">
                <TextBlock Text="{Binding Path=FailedTests.Count}"
                           Margin="0"
                           Foreground="{StaticResource FailColor}"
                           Style="{StaticResource PhoneTextAccentStyle}" />
                <TextBlock Text="/"
                           Margin="0"
                           Foreground="{StaticResource FailColor}"
                           Style="{StaticResource PhoneTextAccentStyle}" />
                <TextBlock Text="{Binding Path=TotalCount}"
                           Margin="0"
                           Foreground="{StaticResource FailColor}"
                           Style="{StaticResource PhoneTextAccentStyle}" />
            </StackPanel>
            <ListBox Grid.Row="2"
                     ItemsSource="{Binding Path=FailedTests}"
                     ItemTemplate="{StaticResource TestResultTemplate}" />
        </Grid>
    </controls:PanoramaItem>

    <controls:PanoramaItem Header="{Binding Path=ResultInconclusiveSectionText, Source={StaticResource Text}}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <ProgressBar Grid.Row="0"
                         Minimum="0"
                         Maximum="{Binding Path=TotalCount}"
                         Value="{Binding Path=InconclusiveTests.Count}"
                         Foreground="{StaticResource InconclusiveColor}"
                         HorizontalAlignment="Stretch" />
            <StackPanel Grid.Row="1"
                        Orientation="Horizontal"
                        Margin="{StaticResource PhoneHorizontalMargin}">
                <TextBlock Text="{Binding Path=InconclusiveTests.Count}"
                           Margin="0"
                           Foreground="{StaticResource InconclusiveColor}"
                           Style="{StaticResource PhoneTextAccentStyle}" />
                <TextBlock Text="/"
                           Margin="0"
                           Foreground="{StaticResource InconclusiveColor}"
                           Style="{StaticResource PhoneTextAccentStyle}" />
                <TextBlock Text="{Binding Path=TotalCount}"
                           Margin="0"
                           Foreground="{StaticResource InconclusiveColor}"
                           Style="{StaticResource PhoneTextAccentStyle}" />
            </StackPanel>
            <ListBox Grid.Row="2"
                     ItemsSource="{Binding Path=InconclusiveTests}"
                     ItemTemplate="{StaticResource TestResultTemplate}" />
        </Grid>
    </controls:PanoramaItem>

    <controls:PanoramaItem Header="{Binding Path=ResultSkipSectionText, Source={StaticResource Text}}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <ProgressBar Grid.Row="0"
                         Minimum="0"
                         Maximum="{Binding Path=TotalCount}"
                         Value="{Binding Path=SkippedTests.Count}"
                         Foreground="{StaticResource SkipColor}"
                         HorizontalAlignment="Stretch" />
            <StackPanel Grid.Row="1"
                        Orientation="Horizontal"
                        Margin="{StaticResource PhoneHorizontalMargin}">
                <TextBlock Text="{Binding Path=SkippedTests.Count}"
                           Margin="0"
                           Foreground="{StaticResource SkipColor}"
                           Style="{StaticResource PhoneTextAccentStyle}" />
                <TextBlock Text="/"
                           Margin="0"
                           Foreground="{StaticResource SkipColor}"
                           Style="{StaticResource PhoneTextAccentStyle}" />
                <TextBlock Text="{Binding Path=TotalCount}"
                           Margin="0"
                           Foreground="{StaticResource SkipColor}"
                           Style="{StaticResource PhoneTextAccentStyle}" />
            </StackPanel>
            <ListBox Grid.Row="2"
                     ItemsSource="{Binding Path=SkippedTests}"
                     ItemTemplate="{StaticResource TestResultTemplate}" />
        </Grid>
    </controls:PanoramaItem>

    <controls:PanoramaItem Header="{Binding Path=ResultTracesSectionText, Source={StaticResource Text}}"
                           Visibility="Collapsed">
        <ListBox ItemsSource="{Binding Path=Traces}"
                 ItemTemplate="{StaticResource TestOutputTemplate}" />
    </controls:PanoramaItem>

</controls:Panorama>
